home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_40041.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  34 lines

  1. -- card: 40041 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. DIRECT CLASSES
  11.  
  12. To avoid the aforementioned problems, classes may be defined using the 'direct' specifier.  In this case the implementation of pointers to objects is NOT a handle, but is simply a pointer.  Using direct classes is also occasionally preferable to avoid overloading the Macintosh memory manager with many small objects.
  13.  
  14. The drawbacks are: (1) the Macintosh memory management routines have less freedom in dynamically restructuring memory since the objects may not be moved, (2) the new() and delete() functions are not defined for 'direct' objects.
  15.  
  16. The second consideration listed above may be overcome by using the standard malloc() and free() C memory allocation functions* in place of new() and delete(), and by declaring this memory as a direct object using the blessD() function in the oops library.  For example, suppose the Person class is 'direct', then a Person object may be declared, allocated, and deallocated as follows:
  17.  
  18.  
  19.  
  20. -- part contents for background part 7
  21. ----- text -----
  22. 128
  23.  
  24. -- part contents for background part 29
  25. ----- text -----
  26. 35106
  27.  
  28. -- part contents for background part 27
  29. ----- text -----
  30. Memory management functions
  31.  
  32. -- part contents for background part 20
  33. ----- text -----
  34. Memory management functions - p197